-- register type's parameters
Param( "float3 Cube::cubeColor" )
Param( "float Cube::cubeSize" )
Param( "float Cube::cubeSizeOffset" )
Param( "float Cube::offsetFrom" )
Param( "float Cube::offsetTo" )

-- register type's functions
Func( "void Cube::Initialize()" )
--Func( "float3 Cube::GetCubeColor()" )
Func( "void Cube::SetCubeColor( float3 )" )
Func( "void Cube::SetCubeSize( float )" )
Func( "void Cube::SetCubeSizeOffset( float )" )

Body( "Cube", "./media/model/unitcube.dae" )
CommonFX( "Cube", "./media/effect/cube.xml" )

function Initialize( params )
	params.cubeColor = float3( 0.5, 0.5, 0.5 )
	params.cubeSize = 1.0
	params.cubeSizeOffset = 0.8
end

function Update( params, deltaTime )
	if params.offsetTo ~= params.offsetFrom then
		gap = params.offsetTo - params.offsetFrom
		gap = deltaTime / 0.5 * gap
		params.cubeSizeOffset = params.cubeSizeOffset + gap
	end
	
	if params.offsetTo > params.offsetFrom then
		if params.cubeSizeOffset > params.offsetTo then
			params.cubeSizeOffset = params.offsetTo
			params.offsetFrom = params.offsetTo
		end
	elseif params.offsetTo < params.offsetFrom then
		if params.cubeSizeOffset < params.offsetTo then
			params.cubeSizeOffset = params.offsetTo
			params.offsetFrom = params.offsetTo
		end
	end
end

function GetCubeColor( params )
	return params.cubeColor
end

function SetCubeColor( params, color )
	params.cubeColor = color
end

function SetCubeSize( params, size )
	params.cubeSize = size
end

function SetCubeSizeOffset( params, offset )
	params.offsetFrom = params.cubeSizeOffset
	params.offsetTo = offset
end
